package com.dense.kuiniu.bookborrow.view.dialog;

import android.content.Context;
import android.view.View;

import com.dense.kuiniu.bookborrow.R;
import com.dense.kuiniu.bookborrow.business.entity.BorrowBook;
import com.dense.kuiniu.bookborrow.business.entity.Reader;
import com.dense.kuiniu.bookborrow.business.itf.OnButtonClickListener;
import com.dense.kuiniu.bookborrow.view.CountDownView;
import com.dense.kuiniu.bookborrow.view.CounterController;

import java.util.List;

/**
 * @author Administrator
 * @date 2020/8/25
 */
public class TickerTapeDialog extends DialogMeasure {
    private CountDownView countDownView;
    private OnButtonClickListener mClickListener;
    private List<BorrowBook> mBorrowBooks;
    private Reader mReader;
    private int mType;

    public TickerTapeDialog(int type, Context context, List<BorrowBook> list,
                            Reader reader, OnButtonClickListener listener) {
        super(context);
        setCanceledOnTouchOutside(false);
        mClickListener = listener;
        mBorrowBooks = list;
        mReader = reader;
        mType = type;
    }

    @Override
    protected int layoutRes() {
        return R.layout.dialog_ticker_tape;
    }

    @Override
    protected void init(Context context, View view) {
        view.findViewById(R.id.tv_exit).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (mClickListener != null) {
                    mClickListener.onCancel();
                }
            }
        });
        view.findViewById(R.id.tv_confirm).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if (mClickListener != null) {
                    mClickListener.onConfirm();
                }
            }
        });
        countDownView = view.findViewById(R.id.count_down_view);
        countDownView.start(new CounterController.OnCompleteListener() {
            @Override
            public void onComplete() {
                dismiss();
                if (mClickListener != null) {
                    mClickListener.onCancel();
                }
            }
        });

    }

    @Override
    public float widthPercent() {
        return 0.78f;
    }

    @Override
    public float heightPercent() {
        return 0.31f;
    }
}